// 全选
class All {
    constructor (pRadio, cRadios) {
        this.pRadio = pRadio;
        this.cRadios = cRadios;

        this.bindEvent();
    }
    bindEvent () {
        this.pRadio.on('change', () => {
            let isCheck = this.pRadio.prop('checked');
            this.changeCRadios(isCheck);
        });

        this.cRadios.on('change', () => {
            let isAll = this.isAll();
            this.pRadio.prop('checked', isAll);
        });
    }
    isAll () {
        let isAll = true;
        $.each(this.cRadios, (ind, item) => {
            if (!$(item).prop('checked')) {
                isAll = false;
                return false;
            }
        });
        return isAll;
    }
    changeCRadios (isCheck) {
        $.each(this.cRadios, (ind, item) => {
            $(item).prop('checked', isCheck);
        });
    }
}